package cn.wanho.service.impl;

import cn.wanho.dao.CmsSummaryMapper;
import cn.wanho.dto.CmsSummary;
import cn.wanho.service.CmsSummaryService;
import cn.wanho.rvo.myeasyexcel.CmsSummaryData;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class CmsSummaryServiceImpl implements CmsSummaryService {
    @Resource
    private CmsSummaryMapper cmsSummaryMapper;
    @Resource
    private RedisTemplate redisTemplate;
    @Override
    public void insert(List<CmsSummaryData> cmsSummaryData,Integer id) {
        for (CmsSummaryData data : cmsSummaryData) {
            CmsSummary cq = new CmsSummary();
            cq.setSort(data.getSort());
            cq.setContent(data.getContent());
            cq.setAnswer(data.getAnswer());
            cq.setValue(data.getValue());
            cmsSummaryMapper.insert(cq);
            System.out.println("数据插入数据库成功！！"+cq);
            redisTemplate.opsForSet().add("wanhocms:paper:summary:"+ id,cq);
        }
    }
}
